import { ref } from 'vue'

export function useLoading() {
  const loading = ref(false)
  const loadingText = ref('')

  const startLoading = (text?: string) => {
    loading.value = true
    loadingText.value = text || '加载中...'
  }

  const stopLoading = () => {
    loading.value = false
    loadingText.value = ''
  }

  return {
    loading,
    loadingText,
    startLoading,
    stopLoading,
  }
}
